package com.ruoyi.web.controller.inv;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.buy.domain.entity.PO.InvWarehouseInfo;
import com.ruoyi.buy.service.IInvWarehouseInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;


/**
 * 仓库管理Controller
 * 
 * @author ruoyi
 * @date 2023-12-12
 */
@RestController
@RequestMapping("/inv/inv0001")
public class InvWarehouseInfoController extends BaseController
{
    @Autowired
    private IInvWarehouseInfoService invWarehouseInfoService;

    /**
     * 查询仓库管理列表
     */

    @GetMapping("/list")
    public AjaxResult list(InvWarehouseInfo invWarehouseInfo)
    {
        List<InvWarehouseInfo> list = invWarehouseInfoService.selectInvWarehouseInfoList(invWarehouseInfo);
        return success(list);
    }

    /**
     * 导出仓库管理列表
     */

    @Log(title = "仓库管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InvWarehouseInfo invWarehouseInfo)
    {
        List<InvWarehouseInfo> list = invWarehouseInfoService.selectInvWarehouseInfoList(invWarehouseInfo);
        ExcelUtil<InvWarehouseInfo> util = new ExcelUtil<InvWarehouseInfo>(InvWarehouseInfo.class);
        util.exportExcel(response, list, "仓库管理数据");
    }

    /**
     * 获取仓库管理详细信息
     */

    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(invWarehouseInfoService.selectInvWarehouseInfoById(id));
    }

    /**
     * 新增仓库管理
     */

    @Log(title = "仓库管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InvWarehouseInfo invWarehouseInfo)
    {
        return toAjax(invWarehouseInfoService.insertInvWarehouseInfo(invWarehouseInfo));
    }

    /**
     * 修改仓库管理
     */
    @Log(title = "仓库管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InvWarehouseInfo invWarehouseInfo)
    {
        return toAjax(invWarehouseInfoService.updateInvWarehouseInfo(invWarehouseInfo));
    }

    /**
     * 删除仓库管理
     */
    @Log(title = "仓库管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(invWarehouseInfoService.deleteInvWarehouseInfoByIds(ids));
    }
}
